﻿using System;
using Model01.Exceptions;

namespace Model01.Objects
{
    /// <summary>
    /// Represents a geographics object.
    /// </summary>
    public class Object : Point
    {
        #region Fields

        private Size size;

        #endregion        

        /// <summary>
        ///
        /// </summary>
        /// <param name="x">X coordinate of the object.</param>
        /// <param name="y">Y coordinate of the object.</param>
        /// <param name="size">Model01.Objects.Size size of the object.</param>
        public Object(int x, int y, Size size) : base(x, y)
        {
            this.size = size;
            this.OnXChange += new OnXChangeEvent(Object_OnXChange);
            this.OnYChange += new OnYChangeEvent(Object_OnYChange);
        }

        #region Events

        /// <summary>
        /// Event occurs when the object is repainting.
        /// </summary>
        public event EventHandler OnPaint = delegate { };            

        protected virtual void Object_OnYChange(object sender, YChangeEventArgs e)
        {
            OnPaint(this, new EventArgs());
        }

        protected virtual void Object_OnXChange(object sender, XChangeEventArgs e)
        {
            OnPaint(this, new EventArgs());
        }

        #endregion

        #region Properties

        /// <summary>
        /// Gets or sets Model01.Objects.Size size of the object.
        /// </summary>
        public Size Size
        {
            get { return size; }
            set { size = value; }
        }

        #endregion
    }
}
